package com.edu.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.edu.bean.Cardetails;
import com.edu.bean.CommonResult;
import com.edu.service.CardetailsService;
import com.edu.service.impl.CardetailsServiceImpl;
@WebServlet("/cardetailselectiddo")
public class SelectCardetailsServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("id");
		int carid = Integer.parseInt(id);
		CardetailsService cs = new CardetailsServiceImpl();
		Cardetails cardetail = cs.selectCardetailsById(carid);
		CommonResult result = new CommonResult();
		result.setCode(200);
		result.setMessage("success");
		result.setData(cardetail);
		resp.setContentType("application/json;charset=utf-8");
		resp.getWriter().write(result.toJsonString());
	}
}
